﻿using XinLife.Application.Interface;
using XinLife.Common;
using XinLife.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using XinLife.Core.Model;

namespace XinLife.Controllers.Admin
{
    /// <summary>
    /// 用户消息
    /// </summary>
    public class UserMsgController : BaseController
    {
        IUserMsgService _userMsgService;
        public UserMsgController(IUserMsgService userMsgService)
        {
            _userMsgService=userMsgService;
        }
        /// <summary>
        /// 获取列表
        /// </summary>
        [HttpGet]
        public async Task<object> GetUserMsgPageList([FromQuery] Pagination pagination, [FromQuery] string queryJson = null)
        {
            return await _userMsgService.GetUserMsgPageList(pagination, queryJson);
        }
        /// <summary>
        /// 获取表单信息
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public async Task<AjaxResult> GetUserMsgForm(string id)
        {
            return await _userMsgService.GetUserMsgForm(id);
        }
        /// <summary>
        /// 删除
        /// </summary>
        [HttpPost]
        public async Task<AjaxResult> DelUserMsg([FromForm] string ids)
        {
            return await _userMsgService.DelUserMsg(ids);
        }
        /// <summary>
        /// 获取用户的未读消息
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public async Task<AjaxResult> GetUnreadMsg()
        {
            return await _userMsgService.GetUnreadMsg();
        }

        /// <summary>
        /// 标记已读
        /// </summary>
        [HttpGet]
        public async Task<AjaxResult> MsgReady(string ids = null)
        {
            return await _userMsgService.MsgReady(ids);
        }

        /// <summary>
        /// 获取所有用户
        /// </summary>
        [HttpGet]
        public async Task<AjaxResult> GetUsers()
        {
            return await _userMsgService.GetUsers();
        }
        /// <summary>
        /// 发送信息
        /// </summary>
        [HttpPost]
        public async Task<AjaxResult> SendMsg([FromForm] UserMsg msg)
        {
            return await _userMsgService.EditUserMsg(msg);
        }
    }
}
